package com.hcq.service;

import com.common.entity.Rsp;
import com.common.entity.Ticket;
import com.hcq.mapper.TicketMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class TicketServiceImpl {

    @Autowired
    TicketMapper ticketMapper;

    public Rsp addMany(List<Ticket> tickets,String userId){

        for (Ticket t : tickets) {
            t.setId(UUID.randomUUID().toString().replaceAll("-",""));
            t.setCreateUserId(userId);
            t.setCreateTime(new Date());
            t.setUpdateUserId(userId);
            t.setUpdateTime(new Date());
            t.setDeleted(Ticket.NO_DELETED);
        }
        Integer result = ticketMapper.addMany(tickets);
        return result == tickets.size()?Rsp.success("成功"):Rsp.fail().msg("失败");
    }
}
